From: Julian Sparber Date: Mon, 26 Feb 2024 10:06:34 +0000 (+0100) Subject: screencapture: Use same source for all screen capture notifications X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~116^2^2~43 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=6e3c0d9dac66b8a8428ae1a01effda65c5e94855;p=gnome-shell.git screencapture: Use same source for all screen capture notifications We group notifications by source but in order to have it working we actually need to use the same source object. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6187 Part-of: --- diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index d96d62b3e..097123321 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -32,6 +32,24 @@ const ScreenshotIface = loadInterfaceXML('org.gnome.Shell.Screenshot'); const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast'); const ScreencastProxy = Gio.DBusProxy.makeProxyWrapper(ScreencastIface); +let screenshotNotificationSource = null; +function getScreenshotNotificationSource() { + if (!screenshotNotificationSource) { + screenshotNotificationSource = new MessageTray.Source({ + // Translators: notification source name for screenshots and recordings. + title: _('Screen Capture'), + iconName: 'screenshooter-symbolic', + }); + + screenshotNotificationSource.connect('destroy', () => { + screenshotNotificationSource = null; + }); + Main.messageTray.add(screenshotNotificationSource); + } + + return screenshotNotificationSource; +} + const IconLabelButton = GObject.registerClass( class IconLabelButton extends St.Button { _init(iconName, label, params) { @@ -2082,11 +2100,7 @@ export const ScreenshotUI = GObject.registerClass({ } _showNotification(title) { - const source = new MessageTray.Source({ - // Translators: notification source name. - title: _('Screenshot'), - iconName: 'screencast-recorded-symbolic', - }); + const source = getScreenshotNotificationSource(); const notification = new MessageTray.Notification({ source, title, @@ -2124,7 +2138,6 @@ export const ScreenshotUI = GObject.registerClass({ Main.panel.closeCalendar(); } - Main.messageTray.add(source); source.addNotification(notification); } @@ -2329,11 +2342,7 @@ function _storeScreenshot(bytes, pixbuf) { ); // Show a notification. - const source = new MessageTray.Source({ - // Translators: notification source name. - title: _('Screenshot'), - iconName: 'screenshot-recorded-symbolic', - }); + const source = getScreenshotNotificationSource(); const notification = new MessageTray.Notification({ source, // Translators: notification title. @@ -2372,7 +2381,6 @@ function _storeScreenshot(bytes, pixbuf) { }); } - Main.messageTray.add(source); source.addNotification(notification); return file;